#include <iostream>
#include <bits/stdc++.h>

using namespace std;
const int N = 2001;
int matrix[N][N];

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        matrix[i][i] = 0;
    }
    int count = (int) (n * (n - 3) / 6 + 1);
    cout << count << "\n";
    //1 2 3 1 5 6 2 4 6 3 4 5
    for (int x = 1; x <= n; x++) {
        for (int y = x + 1; y <= n; y++) {
            for (int k = y + 1; k <= n; k++) {
                if (matrix[x][y] + matrix[y][k] + matrix[x][k] == 0 && x != y && x != k && y != k) {
                    matrix[x][y] = matrix[y][k] = matrix[x][k] = 1;
                    cout << x << " " << y << " " << k << "\n";
                    count--;
                }
                if (count <= 0) {
                    return;
                }
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    solve();
    return 0;
}

//E:\c_c++_code\alo_10_14\test1.exe
//20
//57
//1 2 17
//1 3 16
//1 4 15
//1 5 14
//1 6 13
//1 7 12
//1 8 11
//1 9 10
//1 19 20
//2 3 15
//2 4 14
//2 5 13
//2 6 12
//2 7 11
//2 8 10
//2 18 20
//3 4 13
//3 5 12
//3 6 11
//3 7 10
//3 8 9
//3 17 20
//3 18 19
//4 5 11
//4 6 10
//4 7 9
//4 16 20
//4 17 19
//5 6 9
//5 7 8
//5 15 20
//5 16 19
//5 17 18
//6 14 20
//6 15 19
//6 16 18
//7 13 20
//7 14 19
//7 15 18
//7 16 17
//8 12 20
//8 13 19
//8 14 18
//8 15 17
//9 11 20
//9 12 19
//9 13 18
//9 14 17
//9 15 16
//10 11 19
//10 12 18
//10 13 17
//10 14 16
//11 12 17
//11 13 16
//11 14 15
//12 13 15
//
//进程已结束，退出代码为 0


//E:\c_c++_code\alo_10_14\main.exe
//20
//57
//1 2 3
//1 4 5
//1 6 7
//1 8 9
//1 10 11
//1 12 13
//1 14 15
//1 16 17
//1 18 19
//2 4 6
//2 5 7
//2 8 10
//2 9 11
//2 12 14
//2 13 15
//2 16 18
//2 17 19
//3 4 7
//3 5 6
//3 8 11
//3 9 10
//3 12 15
//3 13 14
//3 16 19
//3 17 18
//4 8 12
//4 9 13
//4 10 14
//4 11 15
//4 16 20
//5 8 13
//5 9 12
//5 10 15
//5 11 14
//5 17 20
//6 8 14
//6 9 15
//6 10 12
//6 11 13
//6 18 20
//7 8 15
//7 9 14
//7 10 13
//7 11 12
//7 19 20
//
//进程已结束，退出代码为 0
